package com.lvmama.rhino.collector.vo

import com.lvmama.rhino.collector.utils.Constants

/**
  * Created by yuanxiaofeng on 2016/3/11.
  */
class EventLog extends Serializable {
  /**
    * pageCode
    * 页面代码
    */
  var _pc: String = _
  /**
    * networkType
    * 网络类型
    */
  var _nt: String = _
  /**
    * timestamp
    * 访问时间戳
    */
  var _ts: Long = _
  /**
    * customMap
    * 自定义数据map
    */
  var _cm: Map[String, String] = _

  def pc = _pc

  def nt = _nt

  def ts = _ts

  def cm = _cm

  def pc_=(v: String): Unit = _pc = v

  def nt_=(v: String): Unit = _nt = v

  def ts_=(v: Long): Unit = _ts = v

  def cm_=(v: Map[String, String]): Unit = _cm = v

  override def toString: String = {
    val builder: StringBuilder = new StringBuilder
    builder.append(if (pc != null) pc else "").append(Constants.LOG_SEPERATOR_1)
    builder.append(if (nt != null) nt else "").append(Constants.LOG_SEPERATOR_1)
    builder.append(_ts).append(Constants.LOG_SEPERATOR_1)
    if (cm != null) {
      for (key <- cm.keySet) {
        builder.append(key).append(Constants.LOG_SEPERATOR_3).append(cm.get(key).get).append(Constants.LOG_SEPERATOR_2)
      }
    } else {
      builder.append(Constants.LOG_SEPERATOR_2)
    }
    builder.toString
  }
}
